home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-08 | 5.0 KB | 157 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CTridentCmd.cp ©1993 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
-
- #include "CTridentCmds.h"
- #include "CTridentApp.h"
- #include "CTridentView.h"
- #include <LCommander.h>
- #include <UException.h>
-
- #ifndef __PPCTOOLBOX__
- #include <PPCToolbox.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
- // ********************************* Constants ************************************* // all new rD
- const OSType kSignature = 'JVLN';
- const OSType kWhoType = 'who ';
- const OSType kJavType = 'updt';
- const short ppcInternetLocation = 3;
- //TApplicationTrident* gApplicationTrident;
-
- // ********************************* Utilities ************************************* //
-
- //--------------------------------------------------------------------------------------------------
-
- /*
- * MyPPCBrowserFilter
- *
- * Thanks to Eric Berhdahl & Eric Soldan and his Kibitz application for the tips
- * on how to implement this funciton.
- */
- static pascal Boolean MyPPCBrowserFilteruptime(LocationNamePtr /* theLocation*/ , PortInfoPtr thePortInfo)
- {
- OSType type;
-
- if (thePortInfo->name.portKindSelector == ppcByString)
- {
- BlockMove(thePortInfo->name.u.portTypeStr + 1, &type, sizeof(type));
- if (type == kSignature)
- return true;
- } else if (thePortInfo->name.portKindSelector == ppcByCreatorAndType)
- {
- if (thePortInfo->name.u.port.portCreator == kSignature &&
- thePortInfo->name.u.port.portType == kJavType)
- // thePortInfo->name.u.port.portType == kWhoType)
- return true;
- }
- return false;
- }
- static pascal Boolean MyPPCBrowserFilterwho(LocationNamePtr /* theLocation*/ , PortInfoPtr thePortInfo)
- {
-
- if (thePortInfo->name.portKindSelector == ppcByCreatorAndType)
- {
- if (thePortInfo->name.u.port.portCreator == kSignature &&
- thePortInfo->name.u.port.portType == kWhoType)
- return true;
- }
- return false;
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- //extern short gDocumentCount = 0;
-
- void MyBrowser(CTridentWindow* theOwner) // OVERRIDE
- {
- static PPCFilterUPP gPortFilter = NULL;
- //CTridentView* tmpView = (CTridentView*) theOwner->FindPaneByID('winb');
- CTridentView* tmpView = (CTridentView*) theOwner->FindPaneByID('winb');
- OSType theType;
-
- if (tmpView != NULL)
- theType = (OSType) tmpView->GetUserCon();
-
- if (gPortFilter == NULL)
- {
- if (theType == kSignature) //'JVLN' the normal one
- gPortFilter = NewPPCFilterProc(MyPPCBrowserFilteruptime);
- else
- gPortFilter = NewPPCFilterProc(MyPPCBrowserFilterwho); //'JVL2'
-
- FailNIL_(gPortFilter);
- }
-
- PortInfoRec thePortInfo;
- TargetID theTargetID;
- OSErr theErr;
- LStr255 windowTitle, tmpString, tmpString2;
- LStr255 theLocNBPType = "\pUNIX PPCToolbox";
- GetIndString(tmpString,kLabelStrings, 2); //"\pSelect a Unix Server."
- GetIndString(tmpString2,kLabelStrings, 1); //"\pServers"
-
- theErr = PPCBrowser(tmpString, tmpString2,
- FALSE /* defaultSpecified */, &(theTargetID.location), &thePortInfo, gPortFilter, theLocNBPType);
- // theErr = PPCBrowser(tmpString, tmpString2,
- // FALSE /* defaultSpecified */, &(theTargetID.location), &thePortInfo, NULL, theLocNBPType);
-
- delete gPortFilter;
- gPortFilter = NULL;
- if (theErr == noErr)
- {
- }
- else if (theErr != userCanceledErr)
- //FailOSErr(theErr);
- DebugStr("\p Some error other than userCanceledErr! Doh!.");
-
- else
- return;
-
- // get the AE Address
- theTargetID.name = thePortInfo.name;
-
- switch (theTargetID.location.locationKindSelector)
- {
- case ppcNoLocation: // my own machine
- // fDocument->SetAddress(theTargetID);
- // fDocument->SetPortRefNum(gNumUntitled);
- // fDocument->SetfWindowTitle(CStr255("This is a local node"));
-
- break;
- case ppcNBPLocation:
- theOwner->SetAddress(theTargetID);
- // theErr = PtrToHand(&theTargetID.location.u.nbpEntity.objStr, &testString, 33);
- BlockMove(&theTargetID.location.u.nbpEntity.objStr, &windowTitle, 33);
- theOwner->SetDescriptor((unsigned char *) &windowTitle);
- if (thePortInfo.name.portKindSelector == ppcByString)
- tmpView->fLegacyCompatable = TRUE; //need to send heartbeats despite other communication
- break;
- default:
- DebugStr("\p Help me Rhonda. If you can read this you're too close.");
- }
-
- // lets check the version number
-
- // InvalidateMenus(); //global routine... not sure who the target is in this case. we'll see.
- // this->WakeupServer();
-
-
- //if (fDocument->Connected())
- // this->CheckVersion();
-
- // Words of wisdom, the nbpEntity record is trash if the PPC selection is on the same
- // local node. It is very important to check the locationKindSelector (as above) and
- // only use the npbEntity record when we have a ppcNBPLocation!!! See IM VI-7 for more
- // information about this (it's well hidden!)
- }
-
-